package com.Txunda.fxw.ui.adapter;

import com.Txunda.fxw.R;
import com.Txunda.fxw.ui.callback.MyItemClickListener;
import com.Txunda.fxw.ui.adapter.model.MyViewHolder;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class RecyclerViewAdapter extends RecyclerView.Adapter<MyViewHolder>{

	private String[]datas;
	private int[]imgs;
	public Context mContext;
	public MyItemClickListener itemClickListener;

	
	public String[] getDatas() {
		return datas;
	}

	public void setDatas(String[] datas) {
		this.datas = datas;
	}

	public int[] getImgs() {
		return imgs;
	}

	public void setImgs(int[] imgs) {
		this.imgs = imgs;
	}
	public RecyclerViewAdapter(Context context,MyItemClickListener itemClickListener){
		this.mContext = context;
		this.itemClickListener = itemClickListener;
	} 

	@Override
	public int getItemCount() {
		return imgs.length;
	}

	@Override
	public void onBindViewHolder(MyViewHolder holder, final int position) {
		holder.getItem_img().setImageResource(imgs[position]);
		
		//��Ŀ����¼�����
		holder.itemView.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
               //Toast.makeText(mContext, "�����"+position, Toast.LENGTH_SHORT).show();				
			}
		});
	}

	@Override
	public MyViewHolder onCreateViewHolder(ViewGroup arg0, int arg1) {
		View view = LayoutInflater.from(mContext).inflate(R.layout.main_item, null);
		MyViewHolder viewHolder =new MyViewHolder(view);
		return viewHolder;
	}

}
